package com.wd.common.api

import com.wd.common.bean.AllQuickSearchBean
import com.wd.common.bean.BanneBean
import com.wd.common.bean.RimRecommendBean
import com.wd.common.bean.BuyCarBean
import com.wd.common.bean.ContrastBean
import com.wd.common.bean.DefaultConditionBean
import com.wd.common.bean.FollowBean
import com.wd.common.bean.HomeRecOneBean
import com.wd.common.bean.UserInfoBean
import com.wd.common.bean.ManyBean
import com.wd.common.bean.NearbyChargeStationBean
import com.wd.common.bean.QuestionBean
import com.wd.common.bean.QuestionXqBean
import com.wd.common.bean.QuickSearchBean
import com.wd.common.bean.SendRimBean
import com.wd.common.bean.TalkBean
import com.wd.common.bean.TalkXqBean
import com.wd.common.bean.TiwenBean
import com.wd.common.bean.ZhuanRimBean
import io.reactivex.Observable
import okhttp3.MultipartBody
import okhttp3.ResponseBody
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Headers
import retrofit2.http.Multipart
import retrofit2.http.PUT
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query
import java.io.File


/**
 * 作者:孙殿彭 by mac on2023/9/5 09:34
 * 类注释:
 */
interface ApiService {
    //首页轮播图
    @GET("car-user/user/v1/findBannerList")
    fun Banne(): Observable<BanneBean>

    //车圈推荐列表
    @GET("car-circle/circle/v1/findCircleRecommendList")
    fun getRecom(@Query("page") page: Int, @Query("size") size: Int): Observable<RimRecommendBean>

    //车圈新能源
    @GET("car-circle/circle/verify/v1/findCircleAttentionList")
    fun getNew(@Query("page") page: Int, @Query("size") size: Int): Observable<RimRecommendBean>

    //关注
    @GET("car-circle/circle/verify/v1/findCircleAttentionList")
    fun getInterest(
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<RimRecommendBean>

    //首页金刚区
    @GET("car-user/user/v1/findNavigationBar")
    fun RecOne(): Observable<HomeRecOneBean>

    //普通登录
    @POST("/car-user/user/v1/login")
    fun userLogin(@Body map: Map<String, String>): Observable<UserInfoBean>
    //

    //首页多条目
    @GET("car-circle/circle/v1/findCircleRecommendList")
    fun ManyRec(@Query("page") page: Int, @Query("size") size: Int): Observable<ManyBean>

    //看车-默认查询条件
    @GET("/car-choose/car/v1/findDefaultCondition")
    fun findDefaultCondition(): Observable<DefaultConditionBean>

    //看车-快速查询
    @POST("/car-choose/car/v1/QuickSearch")
    fun lookQuickSearch(
        @Body map: Map<String, String>,
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<QuickSearchBean>
    @POST("/car-choose/car/v1/multiConditionQuery")
    fun multiConditionQuery(@Query("page") page: Int,
                            @Query("size") size: Int,
                            @Body map: Map<String, String>):Observable<QuickSearchBean>
    //更多条件查询
    @GET("car-choose/car/v1/findAllCondition")
    fun findAllCondition():Observable<AllQuickSearchBean>

    //我的-关注
    @GET("/car-user/user/verify/v1/findAttentionList")
    fun meFollow(
        @Header("userId") userId: Int,
        @Header("token") token: String,
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<FollowBean>

    //找桩充电
    @GET("/car-user/user/v1/findNearbyChargeStation")
    fun nearbyChargeStation(@Query("location") location: String): Observable<NearbyChargeStationBean>

    //3d资源
    @GET("car-choose/car/v1/getCarSpatialModelMedia/{categoryId}")
    suspend fun downloadFile(
        @Path("categoryId") categoryId: String
    ): ResponseBody

//    *********************************** 买车 *******************************

    //查询品牌列表
    @GET("/car-choose/car/v1/findBrandList")
    fun Buycar_querylist(): Observable<BuyCarBean.BuyCarListBean>

    //买车·二手车列表
    @Headers("userId:1")
    @GET("/car-choose/secondCar/v1/findSecondCarList")
    fun Buy_oldcar_list(
        @Query("page") page: Int, @Query("size") size: Int,
    ): Observable<BuyCarBean.BuyOldCarListBean>

    //买车·新车·选择车系二级列表
    @GET("/car-choose/car/v1/findCarModelList")
    fun Buy_newcar_cloose(
        @Query("brandId") brandId: Int,
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<BuyCarBean.BuyNewCar_ChooseList>

    //买车·新车·车系详情
    @GET("/car-choose/car/v1/findCarModelDetail")
    fun Buy_newcar_details(@Query("categoryId") categoryId: Int):
            Observable<BuyCarBean.BuyNewCar_CarDetails>

    //买车·二手车·搜索
    @GET("/car-choose/secondCar/v1/searchSecondCar")
    fun Buy_oldcar_clooselist(
        @Query("keyword") keyword: String,
        @Query("page") page: Int,
        @Query("size") size: Int
    ): Observable<BuyCarBean.Buy_OldCar_clooselist>

    //买车·新车·详情·外观 内饰
    @GET("/car-choose/car/v1/findCarPictureList")
    fun Buy_newcar_wainei(@Query("categoryId") categoryId: Int, @Query("type") type: Int)
            : Observable<BuyCarBean.Buy_NewCar_waineiBean>

    //买车·新车·销量
    @GET("/car-choose/car/v1/findSalesRanking")
    fun Buy_newcar_xiaoliang(@Query("gradeId") gradeId: Int):
            Observable<BuyCarBean.Buy_newcar_XiaoliangBean>

    //买车·二手车·详情
    @GET("/car-choose/secondCar/v1/findSecondCarDetailByCarId")
    fun Buy_oldcar_details(@Query("carId") carId: Int):
            Observable<BuyCarBean.Buy_oldcar_detailsBean>

    //买车·二手车·详情·实拍图片
    @GET("/car-choose/secondCar/v1/findSecondCarImages")
    fun Buy_oldcar_details_img(@Query("carId") carId: Int):
            Observable<BuyCarBean.Buy_oldcar_details_imgBean>

    //买车·二手车·收藏
    @PUT("/car-choose/secondCar/verify/v1/collectSecondCar")
    @Headers("userId:144", "token:1695624129208144")
    fun Buy_oldcar_detailsshoucang(@Query("secondCarId") secondCarId: Int)
            : Observable<BuyCarBean.BuyOldCarShouCangBean>

    //买车·二手车·取消收藏
    @DELETE("/car-choose/secondCar/verify/v1/cancelCollectSecondCar")
    @Headers("userId:144", "token:1695624129208144")
    fun Buy_oldcar_deteleshoucang(@Query("secondCarId") secondCarId: Int)
            : Observable<BuyCarBean.BuyOldCarDeteleShouCangBean>

    //查询收藏列表
    @GET("/car-user/user/verify/v1/findCollectSecondCarList")
    @Headers("userId:144", "token:1695624129208144")
    fun QueryBuyOldCarShouCangList(@Query("page") page: Int, @Query("size") size: Int)
            : Observable<BuyCarBean.QueryBuyOldCarShouCangListBean>

    //买车·二手车·询价咨询
    @POST("/car-choose/secondCar/verify/v1/inquiryPrice")
    @Headers("userId:144", "token:1695624129208144")
    fun Buy_oldcar_Inquiry(@Body requestData: BuyCarBean.RequestData): Observable<BuyCarBean.BuyOldCarInquiryBean>
    //    *********************************** 买车 *******************************


    //发送帖子
    @POST("/car-circle/circle/verify/v1/publishCircle")
    @Multipart
    @Headers("userId:139", "token:1696737630178139")
    fun getSendRim(
        @Query("title") title: String,
        @Query("columnId") columnId: Int,
        @Query("type") type: Int,
        @Query("content") content: String,
        @Query("publishLocation") publishLocation: String,
        @Part images: List<MultipartBody.Part>
    ): Observable<SendRimBean>

    @POST("/car-circle/problem/verify/v1/publishProblem")
    @Multipart
    @Headers("userId:139", "token:1696737630178139")
    fun getTiwen(
        @Query("content") content: String,
        @Query("publishLocation") publishLocation: String,
        @Part images: List<MultipartBody.Part>
    ): Observable<TiwenBean>

    //专区
    @GET("/car-choose/car/v1/findBrandList")
    fun getZhuan(): Observable<ZhuanRimBean>

    //话题
    @GET("/car-circle/circle/v1/findHotTopicList")
    fun getTalk(): Observable<TalkBean>


    @GET("/car-circle/circle/v1/findHotTopicById")
    fun getTalkXq(@Query("hotId") hotId: String): Observable<TalkXqBean>


    //问题列表
    @GET("/car-circle/problem/v1/findProblemList")
    fun getQuestion(
        @Query("page") page: String,
        @Query("size") size: String
    ): Observable<QuestionBean>



    //问题详情
    @GET("/car-circle/problem/v1/findProblemDetail")
    fun getQuestionXq(@Query("problemId")problemId:String):Observable<QuestionXqBean>
    //批量查询参数
    @GET("/car-choose/car/v1/batchFindCarParameterList")
    fun findCarParameter(@Query("carIds")ids : String):Observable<ContrastBean>
}
//这是声明下载的相关监听方法
typealias download_error = suspend (Throwable) -> Unit
typealias download_process = suspend (downloadedSize: Long, length: Long, progress: Float) -> Unit




typealias download_success = suspend (uri: File) -> Unit